package model;

import java.awt.Color;
import java.io.Serializable;

/**
 * A class to represent a player 
 */
public class Player implements Serializable {
	
	private static final long serialVersionUID = 1L;
	private final int playerID;
	private String playerName;
	private Color playerColor; 
	private int	score;
	
	/**
	 * Construct 
	 * @param aPlayerName The name of the player 
	 * @param aPlayerColor The color that will represent the player 
	 */
	public Player(String aPlayerName, Color aPlayerColor, Integer playerID){
		this.setScore(0);
		this.setPlayerColor(aPlayerColor);
		this.setPlayerName(aPlayerName);
		this.playerID = playerID;
	} //constructor 
	
	/**
	 * Set a new player name 
	 * @param Player name to set
	 */
	public void setPlayerName(String playerName) {
		this.playerName = playerName;
	}

	/**
	 * Get the Player Name
	 * @return the player name 
	 */
	public String getPlayerName() {
		return playerName;
	}

	/**
	 * Set the new color to represent the player 
	 * @param Player Color to set
	 */
	public void setPlayerColor(Color playerColor) {
		this.playerColor = playerColor;
	}

	/**
	 * Get the color of the player
	 * @return The the current player color
	 */
	public Color getPlayerColor() {
		return playerColor;
	}

	/**
	 * If the player is a winner of the game. You set's his new score. 
	 * @param score the score to set
	 */
	public void setScore(int score) {
		this.score = score;
	}

	/**
	 * Get the current score of the player. 
	 * @return the current score, default = 0
	 */
	public int getScore() {
		return score;
	}
	
	public int getID() {
		return playerID;
	}
	
	/**
	 *  Overriding toString to be able to print out the object in a readable way
     *  when it is later read from the file.
	 */
	@Override
    public String toString() {
        StringBuffer buffer = new StringBuffer();        
        buffer.append(playerName + "    " + score);
        buffer.append("\n");
        return buffer.toString();
    }
}
